﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Xml.Serialization;

namespace ClassLibraryEntidades
{
    public static class Serializador
    {
        public static byte[] SerializarObjeto(Object instancia_objeto)
        {
            XmlSerializer xs = new XmlSerializer(instancia_objeto.GetType());
            MemoryStream ms = new MemoryStream();
            xs.Serialize(ms, instancia_objeto);
            return ms.GetBuffer();
        }

        public static Object DeserializarObjeto(byte[] array_bytes_objeto,Type tipo)
        {
            XmlSerializer xs = new XmlSerializer(tipo);
            MemoryStream ms = new MemoryStream(array_bytes_objeto);
            return xs.Deserialize(ms);
        }
    }
}
